package com.pi.config;




import com.pi.core.exchange.vo.CommonNameRegistryService;
import com.pi.pro.xcmg.am.common.XcmgAmConstants;
import com.pi.pro.xcmg.am.was.edi.led.common.LedWasXcmgExchangeConstants;
import com.pi.pro.xcmg.am.was.edi.led.service.LedDisplayServiceProxy;
import com.pi.wms.fac.conn.HttpAccessUrl;
import com.pi.wms.fac.conn.HttpclientProxy;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 *
 */
@Configuration
public class LedWmsClientExchangeConfig {



/**==================================================================================================================**/
//  WH101/
/**==================================================================================================================**/

    @Value("${led.api.was.wh101.code}")
    private String ledWh101ServiceCode;

    @Value("${led.api.was.wh101.warehousecode}")
    private String ledWh101Warehousecode;

    /**
    @Value("${wcs.api.was.wh101.token}")
    private String wcsWh101Token;
    **/


    /**
     * Display
     */
    @Value("${led.api.was.wh101.display.client.code}")
    private String ledDisplayWh101ClientCode;

    @Value("${led.api.was.wh101.display.func.displaytext.url}")
    private String ledDisplayTextWh101PostAccessUrl;

    @Value("${led.api.was.wh101.display.func.taskinfo.url}")
    private String ledTaskInfoWh101PostAccessUrl;

    @Value("${led.api.was.wh101.display.func.errorinfo.url}")
    private String ledErrorInfoWh101PostAccessUrl;

    @Value("${led.api.was.wh101.display.func.definfo.url}")
    private String ledDefInfoWh101PostAccessUrl;


/**==================================================================================================================**/
//  all
/**==================================================================================================================**/

    @Bean
    public CommonNameRegistryService ledNameRegistryService(){
        CommonNameRegistryService nameRegistryService = new CommonNameRegistryService(LedWasXcmgExchangeConstants.LED_ENDPOINT_NAMESPACE);
        nameRegistryService.clientnMapping(XcmgAmConstants.clients);
        nameRegistryService.orgnizationMapping(XcmgAmConstants.organizations);
        return nameRegistryService;
    }





/**==================================================================================================================**/
//  WH101
/**==================================================================================================================**/

    /**********************************************/
    //** Display
    /**********************************************/
    @Bean
    public HttpAccessUrl ledDisplayTextWh101PostAccessUrl(){
        HttpAccessUrl accessUrl=new HttpAccessUrl();
        accessUrl.setUrl(this.ledDisplayTextWh101PostAccessUrl);
        return accessUrl;
    }

    @Bean
    public HttpAccessUrl ledTaskInfoWh101PostAccessUrl(){
        HttpAccessUrl accessUrl=new HttpAccessUrl();
        accessUrl.setUrl(this.ledTaskInfoWh101PostAccessUrl);
        return accessUrl;
    }

    @Bean
    public HttpAccessUrl ledErrorInfoWh101PostAccessUrl(){
        HttpAccessUrl accessUrl=new HttpAccessUrl();
        accessUrl.setUrl(this.ledErrorInfoWh101PostAccessUrl);
        return accessUrl;
    }

    @Bean
    public HttpAccessUrl ledDefInfoWh101PostAccessUrl(){
        HttpAccessUrl accessUrl=new HttpAccessUrl();
        accessUrl.setUrl(this.ledDefInfoWh101PostAccessUrl);
        return accessUrl;
    }

    @Bean
    public HttpclientProxy ledDisplayWh101Client(){
        HttpclientProxy client=new HttpclientProxy(this.ledDisplayWh101ClientCode);
        return client;
    }

    @Bean
    public LedDisplayServiceProxy ledDisplayWh101ServiceProxy(){
        LedDisplayServiceProxy proxy=new LedDisplayServiceProxy();
        proxy.setCategory(this.ledWh101ServiceCode);
        proxy.setCode(this.ledWh101ServiceCode+this.ledDisplayWh101ClientCode);
        proxy.setLedDisplayClient(this.ledDisplayWh101Client());
        //proxy.setToken(this.wcsWh101Token);
        proxy.setLedDisplayTextPostAccessUrl(this.ledDisplayTextWh101PostAccessUrl());
        proxy.setLedTaskInfoPostAccessUrl(this.ledTaskInfoWh101PostAccessUrl());
        proxy.setLedErrorInfoPostAccessUrl(this.ledErrorInfoWh101PostAccessUrl());
        proxy.setLedDefInfoPostAccessUrl(this.ledDefInfoWh101PostAccessUrl());
        this.ledNameRegistryService().register(proxy);
        return proxy;
    }



}
